<!doctype html>



  


<html class="theme-next muse use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  
    
      
    

    
  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Microsoft YaHei:300,300italic,400,400italic,700,700italic|consolas:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="HTML5," />








  <link rel="shortcut icon" type="image/x-icon" href="http://ofy7k3v4s.bkt.clouddn.com/mylogo.png?v=5.0.2" />






<meta name="description" content="&amp;#x7B80;&amp;#x4ECB;&amp;#x3001;h5&amp;#x8BED;&amp;#x4E49;&amp;#x5316;&amp;#x6807;&amp;#x7B7E;&amp;#x3001;&amp;#x7ECF;&amp;#x5178;&amp;#x5E03;&amp;#x5C40;123&amp;lt;!--[if lt IE 9]&amp;gt;&amp;lt;script src=&amp;quot;js/html5shiv.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt">
<meta property="og:type" content="article">
<meta property="og:title" content="HTML5知识体系">
<meta property="og:url" content="https://hongqinma.github.io/2015/02/19/HTML5知识体系/index.html">
<meta property="og:site_name" content="HongqinMa' Blog">
<meta property="og:description" content="&amp;#x7B80;&amp;#x4ECB;&amp;#x3001;h5&amp;#x8BED;&amp;#x4E49;&amp;#x5316;&amp;#x6807;&amp;#x7B7E;&amp;#x3001;&amp;#x7ECF;&amp;#x5178;&amp;#x5E03;&amp;#x5C40;123&amp;lt;!--[if lt IE 9]&amp;gt;&amp;lt;script src=&amp;quot;js/html5shiv.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt">
<meta property="og:updated_time" content="2016-12-13T07:09:39.005Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="HTML5知识体系">
<meta name="twitter:description" content="&amp;#x7B80;&amp;#x4ECB;&amp;#x3001;h5&amp;#x8BED;&amp;#x4E49;&amp;#x5316;&amp;#x6807;&amp;#x7B7E;&amp;#x3001;&amp;#x7ECF;&amp;#x5178;&amp;#x5E03;&amp;#x5C40;123&amp;lt;!--[if lt IE 9]&amp;gt;&amp;lt;script src=&amp;quot;js/html5shiv.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '6347850919329138000',
      author: 'Hiraku'
    }
  };
</script>




  <link rel="canonical" href="https://hongqinma.github.io/2015/02/19/HTML5知识体系/"/>


  <title> HTML5知识体系 | HongqinMa' Blog </title>
</head>

<body itemscope itemtype="//schema.org/WebPage" lang="en">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?10010323";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="//schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta custom-logo">
  
    <div class="site-meta-headline">
      <a>
        <img class="custom-logo-image" src="http://ofy7k3v4s.bkt.clouddn.com/photo.jpg"
             alt="HongqinMa' Blog"/>
      </a>
    </div>
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">HongqinMa' Blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">Spell at all costs， to rush you in the future。</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            Categories
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            About
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            Tags
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                HTML5知识体系
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2015-02-19T19:52:31+08:00" content="2015-02-19">
              2015-02-19
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/HTML5/" itemprop="url" rel="index">
                    <span itemprop="name">HTML5</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2015/02/19/HTML5知识体系/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2015/02/19/HTML5知识体系/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          

          
              &nbsp; | &nbsp;
              <span class="page-pv"><i class="fa fa-file-o"></i>
              <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
              </span>
          

          
            <span id="busuanzi_container_page_pv">  <span id="busuanzi_value_page_pv"></span> Views</span>
          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="&#x7B80;&#x4ECB;&#x3001;h5&#x8BED;&#x4E49;&#x5316;&#x6807;&#x7B7E;&#x3001;&#x7ECF;&#x5178;&#x5E03;&#x5C40;"><a href="#&#x7B80;&#x4ECB;&#x3001;h5&#x8BED;&#x4E49;&#x5316;&#x6807;&#x7B7E;&#x3001;&#x7ECF;&#x5178;&#x5E03;&#x5C40;" class="headerlink" title="&#x7B80;&#x4ECB;&#x3001;h5&#x8BED;&#x4E49;&#x5316;&#x6807;&#x7B7E;&#x3001;&#x7ECF;&#x5178;&#x5E03;&#x5C40;"></a>&#x7B80;&#x4ECB;&#x3001;h5&#x8BED;&#x4E49;&#x5316;&#x6807;&#x7B7E;&#x3001;&#x7ECF;&#x5178;&#x5E03;&#x5C40;</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">&lt;!--[if lt IE 9]&gt;</div><div class="line">&lt;script src=&quot;js/html5shiv.min.js&quot;&gt;&lt;/script&gt;</div><div class="line">&lt;![endif]--&gt;</div></pre></td></tr></table></figure>
<ul>
<li>html&#x9AA8;&#x67B6;</li>
<li>&#x7ECF;&#x5178;&#x7F51;&#x9875;&#x5E03;&#x5C40;</li>
<li>&#x8BED;&#x4E49;&#x5316;&#x6807;&#x7B7E; header&#x3001;nav&#x3001;main&#x3001;session&#x3001;article&#x3001;aside&#x3001;figure&#x3001;footer&#x3001;mark&#x3001;progress&#x3001;hgroup(&#x5DF2;&#x5E9F;&#x5F03;)&#x3001;time&#x3001;details&#x3001;bdi&#x3001;command&#x3001;summary&#x3001;rp&#x3001;rt&#x3001;ruby</li>
<li>&#x517C;&#x5BB9;h5&#x6807;&#x7B7E;&#x7684;&#x63D2;&#x4EF6; html5shiv.min.js</li>
</ul>
<hr>
<h2 id="&#x8868;&#x5355;"><a href="#&#x8868;&#x5355;" class="headerlink" title="&#x8868;&#x5355;"></a>&#x8868;&#x5355;</h2><ul>
<li>&#x8868;&#x5355;&#x7C7B;&#x578B; <ul>
<li>text</li>
<li>password</li>
<li>radio</li>
<li>checkbox </li>
<li>button</li>
<li>submit</li>
<li>reset</li>
<li>image</li>
<li>file</li>
<li>hidden</li>
<li>email</li>
<li>color</li>
<li>url</li>
<li>number  <type="number" step="2" max="10" min="5" name="number">&#x3001;search&#x3001;range  <type="range" name="range" value="50">&#x3001;tel&#x3001;time&#x3001;date&#x3001;datetime&#x3001;week&#x3001;month&#x3001;datetime-local</type="range"></type="number"></li>
</ul>
</li>
<li>&#x8868;&#x5355;&#x5143;&#x7D20;</li>
<li>&#x8868;&#x5355;&#x5C5E;&#x6027;<ul>
<li>placeholder &#x5360;&#x4F4D;&#x7B26;</li>
<li>autofocus &#x83B7;&#x53D6;&#x7126;&#x70B9;</li>
<li>multiple &#x6587;&#x4EF6;&#x4E0A;&#x4F20;&#x591A;&#x9009;&#x6216;&#x591A;&#x4E2A;&#x90AE;&#x7BB1;&#x5730;&#x5740;</li>
<li>autocomplete &#x81EA;&#x52A8;&#x5B8C;&#x6210;&#xFF0C;&#x7528;&#x4E8E;form&#x5143;&#x7D20;&#xFF0C;&#x4E5F;&#x53EF;&#x7528;&#x4E8E;&#x90E8;&#x5206;input&#xFF0C;&#x9ED8;&#x8BA4;&#x503C;on</li>
<li>form &#x6307;&#x5B9A;&#x8868;&#x5355;&#x9879;&#x5C5E;&#x4E8E;&#x54EA;&#x4E2A;form&#xFF0C;&#x5904;&#x7406;&#x590D;&#x6742;&#x8868;&#x5355;&#x65F6;&#x4F1A;&#x9700;&#x8981;</li>
<li>novalidate &#x5173;&#x95ED;&#x9A8C;&#x8BC1;&#xFF0C;&#x53EF;&#x7528;&#x4E8E;<form>&#x6807;&#x7B7E;&#xFF0C;&#xFF08;&#x53EA;&#x9002;&#x5E94;&#x7528;form&#xFF09;</form></li>
<li>required &#x9A8C;&#x8BC1;&#x6761;&#x4EF6;&#xFF0C;&#x5FC5;&#x586B;&#x9879;</li>
<li>pattern &#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F; &#x81EA;&#x5B9A;&#x4E49;&#x9A8C;&#x8BC1;&#x89C4;&#x5219;</li>
</ul>
</li>
<li>&#x8868;&#x5355;&#x4E8B;&#x4EF6; inp.oninput&#xFF0C;&#x5185;&#x5BB9;&#x6539;&#x53D8;&#x65F6;&#x89E6;&#x53D1;</li>
</ul>
<h3 id="&#x8868;&#x5355;&#x5143;&#x7D20;-&#x6CE8;&#x610F;-datalist-&#x7684;&#x4F7F;&#x7528;"><a href="#&#x8868;&#x5355;&#x5143;&#x7D20;-&#x6CE8;&#x610F;-datalist-&#x7684;&#x4F7F;&#x7528;" class="headerlink" title="&#x8868;&#x5355;&#x5143;&#x7D20; &#x6CE8;&#x610F; datalist &#x7684;&#x4F7F;&#x7528;"></a>&#x8868;&#x5355;&#x5143;&#x7D20; &#x6CE8;&#x610F; <code>datalist</code> &#x7684;&#x4F7F;&#x7528;</h3><p>&#x8868;&#x5355;&#x5143;&#x7D20;</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">datalist</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">list</span>=<span class="string">&quot;hobby&quot;</span> <span class="attr">name</span>=<span class="string">&quot;hobby&quot;</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">datalist</span> <span class="attr">id</span>=<span class="string">&quot;hobby&quot;</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;basketball&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">option</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;basketball&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">option</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;football&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">option</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;pingpang&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">option</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">datalist</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">keygen</span> <span class="attr">name</span>=<span class="string">&quot;security&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">keygen</span>&gt;</span>&#x52A0;&#x5BC6;&#x7C7B;&#x578B;</div></pre></td></tr></table></figure>
<h3 id="&#x8868;&#x5355;&#x5C5E;&#x6027;"><a href="#&#x8868;&#x5355;&#x5C5E;&#x6027;" class="headerlink" title="&#x8868;&#x5355;&#x5C5E;&#x6027;"></a>&#x8868;&#x5355;&#x5C5E;&#x6027;</h3><ul>
<li>autofocus</li>
<li>placeholder</li>
<li>multiple</li>
<li>autocomplete</li>
</ul>
<hr>
<h2 id="&#x5A92;&#x4F53;"><a href="#&#x5A92;&#x4F53;" class="headerlink" title="&#x5A92;&#x4F53;"></a>&#x5A92;&#x4F53;</h2><h3 id="audio&#x6807;&#x7B7E;"><a href="#audio&#x6807;&#x7B7E;" class="headerlink" title="audio&#x6807;&#x7B7E;"></a>audio&#x6807;&#x7B7E;</h3><h4 id="&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;"><a href="#&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;" class="headerlink" title="&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;"></a>&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;</h4><ul>
<li>controls </li>
<li>autoplay &#x4E24;&#x4E2A;&#x5C5E;&#x6027;</li>
</ul>
<h4 id="&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;-1"><a href="#&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;-1" class="headerlink" title="&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;"></a>&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;</h4><ul>
<li>mp3</li>
<li>ogg</li>
<li>wav</li>
</ul>
<h3 id="video&#x6807;&#x7B7E;"><a href="#video&#x6807;&#x7B7E;" class="headerlink" title="video&#x6807;&#x7B7E;"></a>video&#x6807;&#x7B7E;</h3><h4 id="&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;-2"><a href="#&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;-2" class="headerlink" title="&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;"></a>&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;</h4><ul>
<li>controls </li>
<li>autoplay &#x4E24;&#x4E2A;&#x5C5E;&#x6027;</li>
</ul>
<h4 id="&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;-3"><a href="#&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;-3" class="headerlink" title="&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;"></a>&#x4E09;&#x79CD;&#x5A92;&#x4F53;&#x683C;&#x5F0F;</h4><ul>
<li>mp4</li>
<li>ogg</li>
<li>webm</li>
</ul>
<hr>
<h2 id="DOM&#x6269;&#x5C55;"><a href="#DOM&#x6269;&#x5C55;" class="headerlink" title="DOM&#x6269;&#x5C55;"></a>DOM&#x6269;&#x5C55;</h2><h3 id="&#x83B7;&#x53D6;&#x5143;&#x7D20;"><a href="#&#x83B7;&#x53D6;&#x5143;&#x7D20;" class="headerlink" title="&#x83B7;&#x53D6;&#x5143;&#x7D20;"></a>&#x83B7;&#x53D6;&#x5143;&#x7D20;</h3><ul>
<li><code>document.getElementsByClassName (&apos;class&apos;)</code> <ul>
<li>&#x901A;&#x8FC7;&#x7C7B;&#x540D;&#x83B7;&#x53D6;&#x5143;&#x7D20;&#xFF0C;&#x4EE5;&#x7C7B;&#x6570;&#x7EC4;&#x5F62;&#x5F0F;&#x5B58;&#x5728;&#x3002;</li>
</ul>
</li>
<li><code>document.querySelector(&apos;selector&apos;)</code> <ul>
<li>&#x901A;&#x8FC7;CSS&#x9009;&#x62E9;&#x5668;&#x83B7;&#x53D6;&#x5143;&#x7D20;&#xFF0C;&#x7B26;&#x5408;&#x5339;&#x914D;&#x6761;&#x4EF6;&#x7684;&#x7B2C;1&#x4E2A;&#x5143;&#x7D20;&#x3002;</li>
</ul>
</li>
<li><code>document.querySelectorAll(&apos;selector&apos;)</code> <ul>
<li>&#x901A;&#x8FC7;CSS&#x9009;&#x62E9;&#x5668;&#x83B7;&#x53D6;&#x5143;&#x7D20;&#xFF0C;&#x4EE5;&#x7C7B;&#x6570;&#x7EC4;&#x5F62;&#x5F0F;&#x5B58;&#x5728;&#x3002;</li>
</ul>
</li>
</ul>
<p><em>css&#x5F53;&#x4E2D;&#x53EF;&#x7528;&#x7684;  &#x5728;querySelector&#x4E2D;&#x90FD;&#x80FD;&#x7528;</em></p>
<h3 id="querySelector-querySelectorAll"><a href="#querySelector-querySelectorAll" class="headerlink" title="querySelector querySelectorAll"></a>querySelector querySelectorAll</h3><h3 id="&#x7C7B;&#x540D;&#x64CD;&#x4F5C;-&#x6BD4;&#x8F83;&#x65B9;&#x4FBF;"><a href="#&#x7C7B;&#x540D;&#x64CD;&#x4F5C;-&#x6BD4;&#x8F83;&#x65B9;&#x4FBF;" class="headerlink" title="&#x7C7B;&#x540D;&#x64CD;&#x4F5C;(&#x6BD4;&#x8F83;&#x65B9;&#x4FBF;)"></a>&#x7C7B;&#x540D;&#x64CD;&#x4F5C;(&#x6BD4;&#x8F83;&#x65B9;&#x4FBF;)</h3><ul>
<li><code>this.classList</code>  <ul>
<li><em>!&#x5F53;&#x524D;&#x5143;&#x7D20;&#x7684;class!</em></li>
</ul>
</li>
<li><code>if(this.classList.contains(&apos;active&apos;)) return false;</code> <ul>
<li><em>!&#x5982;&#x679C;&#x5DF2;&#x7ECF;&#x6709;active &#x4E0D;&#x505A;&#x4EFB;&#x4F55;&#x64CD;&#x4F5C;!</em></li>
</ul>
</li>
<li><code>this.classList.remove(&apos;active&apos;);</code> <ul>
<li><em>!&#x6E05;&#x9664;class!</em></li>
</ul>
</li>
<li><code>this.classList.add(&apos;active&apos;);</code> <ul>
<li><em>!&#x5F53;&#x6CA1;&#x6709;&#x9009;&#x4E2D;&#x7684;&#x65F6;&#x5019;  &#x6DFB;&#x52A0;class active!</em></li>
</ul>
</li>
</ul>
<hr>
<ul>
<li><code>Node.classList.add(&apos;class&apos;)</code><ul>
<li>&#x6DFB;&#x52A0;class</li>
</ul>
</li>
<li><code>Node.classList.remove(&apos;class&apos;)</code><ul>
<li>&#x79FB;&#x9664;class</li>
</ul>
</li>
<li><code>Node.classList.toggle(&apos;class&apos;)</code><ul>
<li>&#x5207;&#x6362;class&#xFF0C;&#x6709;&#x5219;&#x79FB;&#x9664;&#xFF0C;&#x65E0;&#x5219;&#x6DFB;&#x52A0;</li>
</ul>
</li>
<li><code>Node.classList.contains(&apos;class&apos;)</code><ul>
<li>&#x68C0;&#x6D4B;&#x662F;&#x5426;&#x5B58;&#x5728;class</li>
</ul>
</li>
</ul>
<p><em>Node&#x6307;&#x4E00;&#x4E2A;&#x6709;&#x6548;&#x7684;DOM&#x8282;&#x70B9;&#xFF0C;&#x662F;&#x4E00;&#x4E2A;&#x901A;&#x79F0;</em></p>
<h3 id="&#x81EA;&#x5B9A;&#x4E49;&#x5C5E;&#x6027;"><a href="#&#x81EA;&#x5B9A;&#x4E49;&#x5C5E;&#x6027;" class="headerlink" title="&#x81EA;&#x5B9A;&#x4E49;&#x5C5E;&#x6027;"></a>&#x81EA;&#x5B9A;&#x4E49;&#x5C5E;&#x6027;</h3><ul>
<li>&#x5728;HTML5&#x4E2D;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x81EA;&#x5B9A;&#x4E49;&#x5C5E;&#x6027;&#xFF0C;&#x5176;&#x683C;&#x5F0F;&#x5982;&#x4E0B;data-*=&#x201D;&#x201D;&#xFF1B;</li>
<li>&#x5982;&#xFF1A;data-info=&#x201D;&#x6211;&#x662F;&#x81EA;&#x5B9A;&#x4E49;&#x5C5E;&#x6027;&#x201D;&#xFF0C;&#x901A;&#x8FC7;Node.dataset[&#x2018;info&#x2019;]&#x53EF;&#x83B7;&#x53D6;&#x5230;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x5C5E;&#x6027;&#x503C;&#x3002;</li>
<li>Node.dataset&#x662F;&#x4EE5;&#x7C7B;&#x6570;&#x7EC4;&#x5F62;&#x5F0F;&#x5B58;&#x5728;&#x7684;</li>
<li>&#x5F53;&#x6211;&#x4EEC;&#x8BBE;&#x7F6E;data-my-name=&#x201D;itcast&#x201D;&#xFF0C;&#x5219;&#x9700;&#x8981;&#x4EE5;&#x9A7C;&#x5CF0;&#x683C;&#x5F0F;&#x624D;&#x80FD;&#x6B63;&#x786E;&#x83B7;&#x53D6;&#xFF08;Node.dataset[&#x2018;myName&#x2019;]&#xFF09;</li>
</ul>
<h4 id="jQuery&#x7684;&#x81EA;&#x5B9A;&#x4E49;&#x5C5E;&#x6027;&#x65B9;&#x6CD5;data"><a href="#jQuery&#x7684;&#x81EA;&#x5B9A;&#x4E49;&#x5C5E;&#x6027;&#x65B9;&#x6CD5;data" class="headerlink" title="jQuery&#x7684;&#x81EA;&#x5B9A;&#x4E49;&#x5C5E;&#x6027;&#x65B9;&#x6CD5;data();"></a>jQuery&#x7684;&#x81EA;&#x5B9A;&#x4E49;&#x5C5E;&#x6027;&#x65B9;&#x6CD5;data();</h4><ul>
<li><em>&#x64CD;&#x4F5C;&#x5185;&#x5B58;</em></li>
<li><em>&#x5F53;&#x6CA1;&#x6709;&#x8BBE;&#x7F6E;&#x8FC7;data&#x7684;&#x65F6;&#x5019;&#x53EF;&#x4EE5;&#x53D6;&#x5230;dom&#x4E0A;&#x7684;&#x5C5E;&#x6027;</em></li>
<li><em>&#x5F53;&#x6211;&#x4EEC;&#x8BBE;&#x7F6E;&#x8FC7;data&#x4E4B;&#x540E; &#x53D6;&#x7684;&#x5C31;&#x662F;&#x5185;&#x5B58;&#x7684;</em></li>
<li><em>user-name userName</em> <ul>
<li>&#x9A7C;&#x5CF0;&#x547D;&#x540D;&#x548C;&#x666E;&#x901A;&#x7684;&#x7C7B;&#x540D;&#x90FD;&#x53EF;&#x4EE5;&#x53D6;&#x5230;&#x503C;</li>
</ul>
</li>
</ul>
<h4 id="&#x76F4;&#x63A5;&#x64CD;&#x4F5C;DOM"><a href="#&#x76F4;&#x63A5;&#x64CD;&#x4F5C;DOM" class="headerlink" title="&#x76F4;&#x63A5;&#x64CD;&#x4F5C;DOM;"></a>&#x76F4;&#x63A5;&#x64CD;&#x4F5C;DOM;</h4><p><code>nav.dataset[&apos;userName&apos;] = &apos;xgc&apos;;</code> </p>
<ul>
<li>&#x5FC5;&#x987B;&#x662F;&#x9A7C;&#x5CF0;&#x547D;&#x540D;</li>
</ul>
<hr>
<h2 id="&#x5168;&#x5C4F;"><a href="#&#x5168;&#x5C4F;" class="headerlink" title="&#x5168;&#x5C4F;"></a>&#x5168;&#x5C4F;</h2><ul>
<li><code>webkitRequestFullScreen()</code></li>
</ul>
<hr>
<h2 id="&#x89C6;&#x9891;&#x64AD;&#x653E;&#x5668;&#x6848;&#x4F8B;"><a href="#&#x89C6;&#x9891;&#x64AD;&#x653E;&#x5668;&#x6848;&#x4F8B;" class="headerlink" title="&#x89C6;&#x9891;&#x64AD;&#x653E;&#x5668;&#x6848;&#x4F8B;"></a>&#x89C6;&#x9891;&#x64AD;&#x653E;&#x5668;&#x6848;&#x4F8B;</h2><blockquote>
<p>&#x89C6;&#x9891;&#x64AD;&#x653E;&#x7684;&#x65B9;&#x6CD5;&#x3001;&#x5C5E;&#x6027;&#x3001;&#x4E8B;&#x4EF6;</p>
</blockquote>
<hr>
<h2 id="history"><a href="#history" class="headerlink" title="history"></a>history</h2><ul>
<li><code>history.go();</code><ul>
<li><em>&#x6B63;&#x4E3A;&#x524D;&#x8FDB;&#xFF0C;&#x8D1F;&#x4E3A;&#x540E;&#x9000;</em></li>
</ul>
</li>
<li><code>history.back();</code><ul>
<li><em>&#x540E;&#x9000;</em></li>
</ul>
</li>
<li><code>history.forward();</code><ul>
<li><em>&#x524D;&#x8FDB;</em></li>
</ul>
</li>
<li><code>history.pushState({key: &apos;itcast&apos;}, &apos;&#x6807;&#x9898;&#x53D8;&#x6CA1;&#x53D8;&apos;, &apos;/test.html&apos;);</code><ul>
<li><em>pushState&#x53EF;&#x4EE5;&#x5F80;&#x5386;&#x53F2;&#x8BB0;&#x5F55;&#x6DFB;&#x52A0;&#x4E00;&#x6761;&#x8BB0;&#x5F55;</em></li>
</ul>
</li>
<li><code>history.replaceState(null, &apos;title&apos;, &apos;./test.html&apos;);</code><ul>
<li><em>&#x66FF;&#x6362;&#x5386;&#x53F2;&#x8BB0;&#x5F55;</em></li>
</ul>
</li>
<li><code>window.onpopstate = function (state) {console.log(state);}</code><ul>
<li><em>&#x76D1;&#x542C;&#x5386;&#x53F2;&#x7684;&#x53D8;&#x5316;&#xFF1F;&#x53EA;&#x6709;&#x5728;&#x70B9;&#x540E;&#x9000;&#x524D;&#x8FDB;&#x65F6;&#x8C03;&#x7528;</em></li>
</ul>
</li>
</ul>
<hr>
<h2 id="&#x672C;&#x5730;&#x5B58;&#x50A8;"><a href="#&#x672C;&#x5730;&#x5B58;&#x50A8;" class="headerlink" title="&#x672C;&#x5730;&#x5B58;&#x50A8;"></a>&#x672C;&#x5730;&#x5B58;&#x50A8;</h2><h3 id="sessionStorage"><a href="#sessionStorage" class="headerlink" title="sessionStorage;"></a>sessionStorage;</h3><ul>
<li><code>window.sessionStorage.setItem(key, val)</code><ul>
<li><em>&#x5B58;&#x4E00;&#x4E2A;&#x6570;&#x636E;</em></li>
</ul>
</li>
<li><code>var val = window.sessionStorage.getItem(key);</code><ul>
<li><em>&#x8BFB;&#x53D6;&#x4E00;&#x4E2A;&#x6570;&#x636E;</em></li>
</ul>
</li>
<li><code>var val = window.sessionStorage.removeItem(key);</code><ul>
<li><em>&#x5220;&#x9664;&#x4E00;&#x4E2A;&#x6570;&#x636E;</em></li>
</ul>
</li>
<li><code>window.sessionStorage.clear();</code><ul>
<li><em>&#x6E05;&#x7A7A;&#x4E00;&#x4E2A;&#x6570;&#x636E;</em></li>
</ul>
</li>
</ul>
<h3 id="localStorage"><a href="#localStorage" class="headerlink" title="localStorage"></a>localStorage</h3><ul>
<li><code>window.localStorage.setItem(key, val);</code><ul>
<li><em>&#x5B58;&#x4E00;&#x4E2A;&#x6570;&#x636E;</em></li>
</ul>
</li>
<li><code>var val = window.localStorage.getItem(key);</code><ul>
<li><em>&#x8BFB;&#x53D6;&#x4E00;&#x4E2A;&#x6570;&#x636E;</em></li>
</ul>
</li>
<li><code>var val = window.localStorage.removeItem(key);</code><ul>
<li><em>&#x5220;&#x9664;&#x4E00;&#x4E2A;&#x6570;&#x636E;</em></li>
</ul>
</li>
<li><code>window.localStorage.clear();</code><ul>
<li><em>&#x6E05;&#x7A7A;&#x4E00;&#x4E2A;&#x6570;&#x636E;</em></li>
</ul>
</li>
</ul>
<hr>
<h2 id="geolocation"><a href="#geolocation" class="headerlink" title="geolocation"></a>geolocation</h2><figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div></pre></td><td class="code"><pre><div class="line">/*&#x5F15;&#x5165;&#x767E;&#x5EA6;&#x5730;&#x56FE;*/</div><div class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;http://api.map.baidu.com/api?v=2.0&amp;ak= 0A5bc3c4fb543c8f9bc54b77bc155724&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span><span class="javascript"></span></div><div class="line">  <span class="comment">/*&#x5982;&#x679C;&#x5B58;&#x5728;&#x8FD9;&#x4E2A;&#x5C5E;&#x6027;&#x5C31;&#x8BF4;&#x660E;&#x6D4F;&#x89C8;&#x5668;&#x652F;&#x6301;&#x5B9A;&#x4F4D;*/</span></div><div class="line">  <span class="keyword">if</span>(navigator.geolocation) {</div><div class="line">    navigator.geolocation.getCurrentPosition(<span class="function"><span class="keyword">function</span> (<span class="params">position</span>) </span>{</div><div class="line">      <span class="keyword">var</span> latitude = position.coords.latitude; <span class="comment">// &#x7EAC;&#x5EA6;</span></div><div class="line">      <span class="keyword">var</span> longitude = position.coords.longitude; <span class="comment">// &#x7ECF;&#x5EA6;</span></div><div class="line">      <span class="built_in">console</span>.log(position);</div><div class="line">      <span class="comment">/********************/</span></div><div class="line">      <span class="comment">// &#x8FD9;&#x4E9B;&#x90FD;&#x662F;&#x5199;&#x6B7B;</span></div><div class="line">      <span class="keyword">var</span> map = <span class="keyword">new</span> BMap.Map(<span class="string">&quot;container&quot;</span>); <span class="comment">// container&#x8868;&#x793A;&#x4E3B;&#x5230;&#x54EA;&#x4E2A;&#x5BB9;&#x5668;</span></div><div class="line">      <span class="comment">// &#x628A;&#x7ECF;&#x5EA6;&#x7EAC;&#x5EA6;&#x4F20;&#x7ED9;&#x767E;&#x5EA6;</span></div><div class="line">      <span class="keyword">var</span> point = <span class="keyword">new</span> BMap.Point(longitude, latitude);</div><div class="line">      map.centerAndZoom(point, <span class="number">15</span>);</div><div class="line">      <span class="comment">/****************************/</span></div><div class="line">      <span class="comment">// &#x53EA;&#x5199;&#x4E0A;&#x9762;&#x4E09;&#x884C;&#x5C31;&#x53EF;&#x51FA;&#x73B0;&#x5730;&#x56FE;&#x4E86;&#xFF0C;&#x5E76;&#x4E14;&#x4F1A;&#x5B9A;&#x4F4D;</span></div><div class="line">      <span class="comment">// &#x5B9A;&#x4E49;&#x597D;&#x4E86;&#x4E00;&#x4E2A;&#x56FE;&#x7247;&#x6807;&#x8BB0;</span></div><div class="line">      <span class="keyword">var</span> myIcon = <span class="keyword">new</span> BMap.Icon(<span class="string">&quot;http://developer.baidu.com/map/jsdemo/img/fox.gif&quot;</span>, <span class="keyword">new</span> BMap.Size(<span class="number">300</span>, <span class="number">157</span>));</div><div class="line">      <span class="comment">// &#x521B;&#x5EFA;&#x6807;&#x6CE8;</span></div><div class="line">      <span class="keyword">var</span> marker = <span class="keyword">new</span> BMap.Marker(point, {<span class="attr">icon</span>: myIcon});</div><div class="line">      map.addOverlay(marker);</div><div class="line">    });</div><div class="line">  }</div><div class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div></pre></td></tr></table></figure>
<hr>
<h2 id="&#x7F13;&#x5B58;&#x6280;&#x672F;"><a href="#&#x7F13;&#x5B58;&#x6280;&#x672F;" class="headerlink" title="&#x7F13;&#x5B58;&#x6280;&#x672F;"></a>&#x7F13;&#x5B58;&#x6280;&#x672F;</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line">CACHE MANIFEST</div><div class="line">CACHE:</div><div class="line">#&#x6B64;&#x90E8;&#x5206;&#x5199;&#x9700;&#x8981;&#x7F13;&#x5B58;&#x7684;&#x8D44;&#x6E90; &#xFF08;#&#x662F;&#x6CE8;&#x91CA;&#x7684;&#x610F;&#x601D;&#xFF09;</div><div class="line">./images/img1.jpg</div><div class="line">./images/img2.jpg</div><div class="line">./images/img3.jpg</div><div class="line">./images/img4.jpg</div><div class="line">./images/img5.jpg</div><div class="line">NETWORK: </div><div class="line">#&#x6B64;&#x90E8;&#x5206;&#x8981;&#x5199;&#x9700;&#x8981;&#x6709;&#x7F51;&#x7EDC;&#x624D;&#x53EF;&#x8BBF;&#x95EE;&#x7684;&#x8D44;&#x6E90;&#xFF0C;&#x65E0;&#x7F51;&#x7EDC;&#x521A;&#x4E0D;&#x8BBF;&#x95EE;</div><div class="line">./js/main.js</div><div class="line">*</div><div class="line">FALLBACK:</div><div class="line">#&#x5F53;&#x8BBF;&#x95EE;&#x4E0D;&#x5230;&#x67D0;&#x4E2A;&#x8D44;&#x6E90;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x81EA;&#x52A8;&#x7531;&#x53E6;&#x4E00;&#x4E2A;&#x8D44;&#x6E90;&#x66FF;&#x6362;</div><div class="line">./css/online.css ./css/offline.css</div><div class="line">./online.html ./offline.html</div></pre></td></tr></table></figure>
<hr>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;!DOCTYPE html&gt;</span></div><div class="line"><span class="comment">&lt;!--&#x662F;&#x4E0D;&#x662F;&#x505A;&#x79BB;&#x7EBF;&#x7F13;&#x5B58;  &#x7F13;&#x51B2;&#x6E05;&#x5355;--&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">&quot;en&quot;</span> <span class="attr">manifest</span>=<span class="string">&quot;./study.appcache&quot;</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">&quot;UTF-8&quot;</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">title</span>&gt;</span>Application Cache<span class="tag">&lt;/<span class="name">title</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">link</span> <span class="attr">rel</span>=<span class="string">&quot;stylesheet&quot;</span> <span class="attr">href</span>=<span class="string">&quot;./css/main.css&quot;</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">link</span> <span class="attr">rel</span>=<span class="string">&quot;stylesheet&quot;</span> <span class="attr">href</span>=<span class="string">&quot;./css/online.css&quot;</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;./images/img1.jpg&quot;</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;./images/img2.jpg&quot;</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;./images/img3.jpg&quot;</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;./images/img4.jpg&quot;</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;./images/img5.jpg&quot;</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;./js/main.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></div></pre></td></tr></table></figure>
<hr>
<h2 id="&#x62D6;&#x62FD;"><a href="#&#x62D6;&#x62FD;" class="headerlink" title="&#x62D6;&#x62FD;"></a>&#x62D6;&#x62FD;</h2><p>###&#x5173;&#x952E;&#x4EE3;&#x7801;</p>
<p><code>&lt;div class=&quot;box&quot; draggable=&quot;true&quot;&gt;&lt;/div&gt;</code></p>
<h4 id="&#x62D6;&#x62FD;&#x5143;&#x7D20;"><a href="#&#x62D6;&#x62FD;&#x5143;&#x7D20;" class="headerlink" title="&#x62D6;&#x62FD;&#x5143;&#x7D20;"></a>&#x62D6;&#x62FD;&#x5143;&#x7D20;</h4><ul>
<li>drag</li>
<li>dragleave</li>
<li>dragstart</li>
<li>dragend</li>
</ul>
<h4 id="&#x76EE;&#x6807;&#x5143;&#x7D20;"><a href="#&#x76EE;&#x6807;&#x5143;&#x7D20;" class="headerlink" title="&#x76EE;&#x6807;&#x5143;&#x7D20;"></a>&#x76EE;&#x6807;&#x5143;&#x7D20;</h4><ul>
<li>dragover &#x5728;&#x76EE;&#x6807;&#x5143;&#x7D20;&#x4E0A;&#x79FB;&#x52A8;</li>
<li>drop</li>
<li>dragleave</li>
<li>e.preventDefault(); <ul>
<li><em>&#x963B;&#x6B62;&#x6D4F;&#x89C8;&#x5668;&#x9ED8;&#x8BA4;&#x884C;&#x4E3A;</em></li>
</ul>
</li>
</ul>
<hr>
<h2 id="&#x6587;&#x4EF6;&#x4E0A;&#x4F20;"><a href="#&#x6587;&#x4EF6;&#x4E0A;&#x4F20;" class="headerlink" title="&#x6587;&#x4EF6;&#x4E0A;&#x4F20;"></a>&#x6587;&#x4EF6;&#x4E0A;&#x4F20;</h2><p><em>&#x6587;&#x4EF6;&#x9009;&#x62E9;&#x7684;&#x4E00;&#x4E2A;&#x4E8B;&#x4EF6;file.onchange</em></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;file&quot;</span> <span class="attr">class</span>=<span class="string">&quot;file&quot;</span> <span class="attr">multiple</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">script</span>&gt;</span><span class="javascript"></span></div><div class="line">        <span class="comment">/*&#x6587;&#x4EF6;&#x5BF9;&#x8C61;*/</span></div><div class="line">    <span class="keyword">var</span> file = <span class="built_in">document</span>.querySelector(<span class="string">&apos;.file&apos;</span>);</div><div class="line">        <span class="comment">/*&#x6587;&#x4EF6;&#x9009;&#x62E9;&#x7684;&#x4E00;&#x4E2A;&#x4E8B;&#x4EF6;*/</span></div><div class="line">    file.onchange = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{</div><div class="line">      <span class="keyword">var</span> reader = <span class="keyword">new</span> FileReader();</div><div class="line">      reader.readAsDataURL(<span class="keyword">this</span>.files[<span class="number">0</span>]);</div><div class="line">      reader.onload = <span class="function"><span class="keyword">function</span> (<span class="params">ev</span>) </span>{</div><div class="line">        <span class="built_in">document</span>.querySelector(<span class="string">&apos;#img&apos;</span>).src = <span class="keyword">this</span>.result;</div><div class="line">      }</div><div class="line">    }</div><div class="line">  <span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></div></pre></td></tr></table></figure>
<hr>
<h3 id="&#x7F51;&#x7EDC;&#x76D1;&#x542C;&#x7684;&#x4E8B;&#x4EF6;"><a href="#&#x7F51;&#x7EDC;&#x76D1;&#x542C;&#x7684;&#x4E8B;&#x4EF6;" class="headerlink" title="&#x7F51;&#x7EDC;&#x76D1;&#x542C;&#x7684;&#x4E8B;&#x4EF6;"></a>&#x7F51;&#x7EDC;&#x76D1;&#x542C;&#x7684;&#x4E8B;&#x4EF6;</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;jquery.min.js&quot;</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span><span class="javascript"></span></div><div class="line">  <span class="comment">// &#x7F51;&#x7EDC;&#x76D1;&#x542C;&#x7684;&#x4E8B;&#x4EF6;</span></div><div class="line">  <span class="comment">// 10 online &#x5728;&#x7EBF; offline &#x79BB;&#x7EBF;</span></div><div class="line">  <span class="comment">// &#x4E8B;&#x4EF6;&#x662F;&#x7ED9;window&#x7ED1;&#x8BA2;&#x7684;</span></div><div class="line">  <span class="comment">// &#x901A;&#x8FC7;window.navigator.onLine&#x53EF;&#x4EE5;&#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x7684;&#x7F51;&#x7EDC;&#x72B6;&#x6001;</span></div><div class="line">  <span class="built_in">window</span>.addEventListener(<span class="string">&apos;online&apos;</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{</div><div class="line">    <span class="comment">//alert(&apos;online&apos;);</span></div><div class="line">    $(<span class="string">&apos;.tips&apos;</span>).text(<span class="string">&apos;&#x7F51;&#x7EDC;&#x5DF2;&#x8FDE;&#x63A5;&apos;</span>).fadeIn(<span class="number">500</span>).delay(<span class="number">1000</span>).fadeOut();</div><div class="line">  });</div><div class="line">  <span class="built_in">window</span>.addEventListener(<span class="string">&apos;offline&apos;</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{</div><div class="line">    <span class="comment">//alert(&apos;offline&apos;);</span></div><div class="line">    $(<span class="string">&apos;.tips&apos;</span>).text(<span class="string">&apos;&#x7F51;&#x7EDC;&#x5DF2;&#x65AD;&#x5F00;&apos;</span>).fadeIn(<span class="number">500</span>).delay(<span class="number">1000</span>).fadeOut();</div><div class="line">  });</div><div class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div></pre></td></tr></table></figure>
<hr>
<h2 id="canvas"><a href="#canvas" class="headerlink" title="canvas"></a>canvas</h2><h3 id="&#x7B80;&#x4ECB;"><a href="#&#x7B80;&#x4ECB;" class="headerlink" title="&#x7B80;&#x4ECB;"></a>&#x7B80;&#x4ECB;</h3><p>&#x4F7F;&#x7528; canvas &#x7ED8;&#x56FE;</p>
<ul>
<li>&#x4E00;&#x5B9A;&#x8981;&#x6709;&#x4E00;&#x4E2A; canvas &#x6807;&#x7B7E;. canvas &#x6807;&#x7B7E;&#x4E0D;&#x80FD;&#x591F;&#x7ED8;&#x56FE;, &#x5B83;&#x53EA;&#x662F;&#x753B;&#x5E03;, &#x4F46;&#x662F;&#x5B83;&#x53EF;&#x4EE5;&#x83B7;&#x5F97;&#x7ED8;&#x56FE;&#x5DE5;&#x5177;&#x5BF9;&#x8C61;.</li>
<li>&#x7ED8;&#x56FE;&#x5DE5;&#x5177;&#x5BF9;&#x8C61;&#x63D0;&#x4F9B;&#x4E86;&#x5404;&#x79CD;&#x7ED8;&#x56FE;&#x7684; api( &#x51FD;&#x6570;, &#x65B9;&#x6CD5; ), &#x9700;&#x8981;&#x7ED8;&#x5236;&#x4EC0;&#x4E48;&#x5F62;&#x72B6;&#x7684;&#x65F6;&#x5019;&#x5C31;&#x8C03;&#x7528;&#x4EC0;&#x4E48;&#x65B9;&#x6CD5;&#x5373;&#x53EF;.</li>
</ul>
<p>&#x83B7;&#x5F97;&#x7ED8;&#x56FE;&#x5DE5;&#x5177;&#x5BF9;&#x8C61; <code>canvas.getContext(&apos;2d&apos;);</code>  // &#x2018;webgl&#x2019;</p>
<p>&#x5177;&#x4F53;&#x5982;&#x4E0B;&#xFF1A;</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">canvas</span> <span class="attr">width</span>=<span class="string">&quot;600&quot;</span> <span class="attr">height</span>=<span class="string">&quot;300&quot;</span>&gt;</span></div><div class="line">  &#x4F60;&#x597D;, &#x60A8;&#x7684;&#x6D4F;&#x89C8;&#x5668;&#x4E0D;&#x652F;&#x6301; Canvas, &#x8BF7;&#x5347;&#x7EA7;....</div><div class="line"><span class="tag">&lt;/<span class="name">canvas</span>&gt;</span></div><div class="line">var cases = document.getElementsByTagName(&apos;canvas&apos;);</div><div class="line">var context = cases[0].getContext(&quot;2d&quot;);</div></pre></td></tr></table></figure>
<h3 id="canvas-getContext-&#x7684;-API"><a href="#canvas-getContext-&#x7684;-API" class="headerlink" title="canvas.getContext &#x7684; API"></a><code>canvas.getContext</code> &#x7684; API</h3><p>&#x72B6;&#x6001;&#xFF1A;&#x51E1;&#x662F;&#x6D89;&#x53CA;&#x5230; &#x989C;&#x8272;, &#x7EBF;&#x5BBD;, &#x865A;&#x7EBF;, &#x7EBF;&#x5E3D;, &#x62D0;&#x70B9;, &#x63CF;&#x8FB9;, &#x586B;&#x5145; &#x7B49;&#x7B49;&#x90FD;&#x662F;&#x7ED8;&#x56FE;&#x65F6;&#x7684;&#x72B6;&#x6001;.</p>
<p><code>context.beginPath();</code> // &#x5F00;&#x542F;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x8DEF;&#x5F84;</p>
<p>&#x5B9E;&#x9645;&#x4E0A;, &#x5F00;&#x59CB;&#x7ED8;&#x56FE;&#x7684;&#x65F6;&#x5019;:</p>
<ul>
<li>&#x7CFB;&#x7EDF;&#x5C31;&#x9ED8;&#x8BA4;&#x7684;&#x6709;&#x4E00;&#x4E2A; beginPath &#x884C;&#x4E3A;</li>
<li>&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x9636;&#x6BB5;&#x7ED8;&#x5236;&#x7ED3;&#x675F;&#x4E86;, &#x9700;&#x8981;&#x5F00;&#x542F;&#x4E00;&#x4E2A;&#x65B0;&#x7684; beginPath</li>
<li>&#x63A5;&#x7740;&#x7ED8;&#x5236;&#x53E6;&#x4E00;&#x4E2A;&#x9636;&#x6BB5;&#x7684;&#x56FE;&#x50CF;.&#x8FD9;&#x4E2A;&#x9636;&#x6BB5;&#x5C31;&#x662F;&#x72B6;&#x6001;.</li>
<li>&#x8FD9;&#x4E2A;&#x72B6;&#x6001;&#x5C31;&#x662F;&#x6307;:&#x7EBF;&#x5BBD;, &#x989C;&#x8272;, &#x7AEF;&#x70B9;&#x72B6;&#x6001;, &#x7EBF;&#x72B6;&#x6001;, &#x63CF;&#x8FB9;&#x8FD8;&#x662F;&#x586B;&#x5145;</li>
</ul>
<p>&#x5728;&#x5F00;&#x542F;&#x65B0;&#x8DEF;&#x5F84;&#x65F6;, &#x7ED8;&#x5236;&#x5DE5;&#x5177;&#x7684;&#x72B6;&#x6001;&#x6570;&#x636E;&#x4F1A;&#x88AB;&#x7EE7;&#x627F;&#x4E0B;&#x6765;,&#x5373;&#x524D;&#x9762;&#x8BBE;&#x7F6E;&#x7684;&#x72B6;&#x6001;&#x4F1A;&#x88AB;&#x540E;&#x9762;&#x4FDD;&#x7559;, &#x5982;&#x679C;&#x9700;&#x8981;&#x542F;&#x7528;&#x539F;&#x6765;&#x7684;&#x72B6;&#x6001;&#x6709;&#x4E24;&#x4E2A;&#x65B9;&#x6CD5;</p>
<ul>
<li>&#x624B;&#x52A8;&#x8BBE;&#x7F6E;&#x72B6;&#x6001;</li>
<li>&#x5B58;&#x50A8;&#x6062;&#x590D;&#x72B6;&#x6001;</li>
</ul>
<p>&#x4F7F;&#x7528;&#x573A;&#x666F;:</p>
<ul>
<li>&#x5982;&#x679C;&#x7ED8;&#x5236;&#x4E86;&#x4E00;&#x4E2A;&#x56FE;&#x5F62;, &#x4F46;&#x662F;&#x4E34;&#x65F6;&#x8981;&#x7ED8;&#x5236;&#x53E6;&#x4E00;&#x4E2A;&#x56FE;&#x5F62;</li>
<li><p>&#x5728;&#x7ED8;&#x5236;&#x5B8C;&#x8FD9;&#x4E2A;&#x56FE;&#x5F62;&#x540E;, &#x8FD8;&#x9700;&#x8981;&#x56DE;&#x5230;&#x539F;&#x6765;&#x7684;&#x72B6;&#x6001;&#x4E2D;&#x7EE7;&#x7EED;&#x7ED8;&#x5236;</p>
</li>
<li><p><code>context.moveTo( x, y );</code></p>
<ul>
<li>&#x544A;&#x8BC9;&#x8BA1;&#x7B97;&#x673A;&#x4ECE;&#x4EC0;&#x4E48;&#x5730;&#x65B9;&#x5F00;&#x59CB;&#x7ED8;&#x5236;</li>
</ul>
</li>
<li><code>context.lineTo( x, y );</code><ul>
<li>&#x544A;&#x8BC9;&#x8BA1;&#x7B97;&#x673A;&#x4ECE;&#x5F53;&#x524D;&#x4F4D;&#x7F6E;&#x63CF;&#x70B9;&#x5230;&#x54EA;&#x91CC;</li>
</ul>
</li>
<li><code>context.stroke();</code><ul>
<li>&#x63CF;&#x8FB9;&#xFF0C;&#x5C06;&#x524D;&#x9762;&#x63CF;&#x70B9;&#x7528;&#x7EBF;&#x4F9D;&#x6B21;&#x8FDE;&#x63A5;&#x8D77;&#x6765;</li>
</ul>
</li>
<li><code>context.fill();</code><ul>
<li>&#x586B;&#x5145; &#x5982;&#x679C;&#x63CF;&#x70B9;&#x7684;&#x66F2;&#x7EBF;&#x4E0D;&#x95ED;&#x5408;,&#x90A3;&#x4E48;&#x5C06;&#x81EA;&#x52A8;&#x5C06;&#x8D77;&#x70B9;&#x4E0E;&#x7EC8;&#x70B9;&#x8FDE;&#x63A5;&#x8D77;&#x6765;&#x586B;&#x5145;</li>
</ul>
</li>
<li><code>context.lineWidth = &#x6570;&#x5B57;;</code><ul>
<li>&#x8BBE;&#x7F6E;&#x7EBF;&#x5BBD;</li>
</ul>
</li>
<li><code>context.strokeStyle = &#x8868;&#x793A;&#x989C;&#x8272;&#x7684;&#x5B57;&#x7B26;&#x4E32;;</code><ul>
<li>&#x63CF;&#x8FB9;&#x989C;&#x8272;</li>
</ul>
</li>
<li><code>context.fillStyle = &#x8868;&#x793A;&#x989C;&#x8272;&#x7684;&#x5B57;&#x7B26;&#x4E32;;</code><ul>
<li>&#x586B;&#x5145;&#x989C;&#x8272;</li>
</ul>
</li>
<li><code>context.font = &apos;50px &#x9ED1;&#x4F53;&apos;;</code><ul>
<li>&#x8BBE;&#x7F6E;&#x5B57;&#x4F53;</li>
</ul>
</li>
<li><code>context.setLineDash(&#x6570;&#x7EC4;);</code><ul>
<li>&#x7ED8;&#x5236;&#x865A;&#x7EBF;</li>
</ul>
</li>
</ul>
<p>&#x6570;&#x7EC4;&#x662F;&#x63CF;&#x8FF0;&#x5B9E;&#x90E8;&#x4E0E;&#x865A;&#x90E8;&#x7684;&#x957F;&#x5EA6;.</p>
<ul>
<li>&#x4E3A;[]&#x65F6;&#x8868;&#x793A;&#x7ED8;&#x5236;&#x5B9E;&#x7EBF;;</li>
<li>[value1,value2]&#x8868;&#x793A;&#x865A;&#x7EBF;&#x7684;&#x5B9E;&#x90E8;&#x548C;&#x865A;&#x90E8;;</li>
<li>[val1,val2,val3,&#x2026;]&#x8868;&#x793A;&#x865A;&#x7EBF;&#x7684;&#x5B9E;&#x90E8;&#x548C;&#x865A;&#x90E8;&#x4EA4;&#x66FF;&#x53D6;&#x503C;&#xFF0C;&#x53D6;&#x5B8C;&#x4E4B;&#x540E;&#x518D;&#x5FAA;&#x73AF;&#x53D6;&#x503C;&#x3002;</li>
<li><code>context.save();</code><ul>
<li>&#x4FDD;&#x5B58;&#x5F53;&#x524D;&#x72B6;&#x6001;,&#x90A3;&#x4E48;&#x540E;&#x9762;&#x53EF;&#x4EE5;&#x5BF9;&#x72B6;&#x6001;&#x505A;&#x4EFB;&#x4F55;&#x4FEE;&#x6539;</li>
</ul>
</li>
<li><code>context.restore();</code><ul>
<li>&#x5728;&#x60F3;&#x8981;&#x56DE;&#x5230;&#x539F;&#x6765;&#x7684;&#x72B6;&#x6001;&#x65F6;, &#x8C03;&#x7528;&#x6B64;&#x65B9;&#x6CD5;</li>
</ul>
</li>
<li><code>context.closePath();</code><ul>
<li>&#x5982;&#x679C;&#x662F;&#x7ED8;&#x5236;&#x95ED;&#x5408;&#x7684;&#x66F2;&#x7EBF;, &#x90A3;&#x4E48;&#x6700;&#x540E;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <ul>
<li>&#x5982;&#x679C;&#x7ED8;&#x5236;&#x7684;&#x6298;&#x7EBF;, &#x90A3;&#x4E48;&#x4E24;&#x6761;&#x7EBF;&#x6BB5;&#x4E4B;&#x95F4;&#x4F1A;&#x81EA;&#x52A8;&#x8865;&#x5168;&#x5C16;&#x89D2;</li>
<li>&#x5982;&#x679C;&#x4E0D;&#x662F;&#x8FDE;&#x7EED;&#x7684;&#x6298;&#x7EBF;, &#x90A3;&#x4E48;&#x95ED;&#x5408;&#x7684;&#x4E24;&#x6761;&#x7EBF;&#x6BB5;, &#x662F;&#x4E0D;&#x4F1A;&#x8865;&#x5168;&#x5C16;&#x89D2;</li>
</ul>
</li>
</ul>
</li>
<li>&#x5E94;&#x7528;&#xFF1A;&#x53EF;&#x4EE5;&#x5229;&#x7528;x&#xFF0C;y&#x7684;&#x5750;&#x6807;&#x7684;&#x6570;&#x5B66;&#x51FD;&#x6570;&#x7684;&#x5173;&#x7CFB;&#x6765;&#x7ED8;&#x5236;&#x5404;&#x79CD;&#x66F2;&#x7EBF;</li>
<li><code>context.strokeRect(x&#x5750;&#x6807;,y&#x5750;&#x6807;,&#x5BBD;,&#x9AD8;);</code><ul>
<li>&#x63CF;&#x8FB9;&#x77E9;&#x5F62;</li>
</ul>
</li>
<li><code>context.fillRect(x&#x5750;&#x6807;,y&#x5750;&#x6807;,&#x5BBD;,&#x9AD8;);</code><ul>
<li>&#x586B;&#x5145;&#x77E9;&#x5F62;</li>
</ul>
</li>
<li><code>context.clearRect(x&#x5750;&#x6807;,y&#x5750;&#x6807;,&#x5BBD;,&#x9AD8;);</code><ul>
<li>&#x64E6;&#x9664;&#x77E9;&#x5F62;&#x533A; &#x5E94;&#x7528;&#xFF1A;&#x505A;&#x52A8;&#x753B;</li>
</ul>
</li>
<li><code>context.arc(x&#x5750;&#x6807;,y&#x5750;&#x6807;,&#x534A;&#x5F84;,&#x8D77;&#x59CB;&#x89D2;,&#x7EC8;&#x70B9;&#x89D2;&#x5EA6;);</code><ul>
<li>&#x89D2;&#x5EA6;&#x662F;&#x5F27;&#x5EA6;&#x5236;</li>
</ul>
</li>
<li><code>context.strokeText(&apos;&#x6D4B;&#x8BD5;&#x6587;&#x5B57;&apos;,100,100 );</code><ul>
<li>&#x63CF;&#x8FB9;&#x6587;&#x672C;</li>
</ul>
</li>
<li><code>context.fillText(&apos;&#x6D4B;&#x8BD5;&#x6587;&#x5B57;&apos;,300,100);</code><ul>
<li>&#x586B;&#x5145;&#x6587;&#x672C; </li>
</ul>
</li>
<li>&#x7ED8;&#x56FE;&#x7B2C;&#x4E00;&#x79CD;&#x7528;&#x6CD5;,&#x5C06;&#x6574;&#x4E2A;&#x56FE;&#x7247;&#x6309;&#x7167;&#x672C;&#x8EAB;&#x7684;&#x5BBD;&#x9AD8;&#x7ED8;&#x5236;&#x5230;&#x7ED8;&#x5E03;&#x4E0A; <ul>
<li><code>context.drawImage(img,x&#x8F74;&#x5750;&#x6807;,y&#x8F74;&#x5750;&#x6807;);</code></li>
</ul>
</li>
<li>&#x7ED8;&#x56FE;&#x7B2C;&#x4E8C;&#x79CD;&#x7528;&#x6CD5;, &#x5C06;&#x56FE;&#x7ED8;&#x5236;&#x5728;&#x6307;&#x5B9A;&#x7684;&#x77E9;&#x5F62;&#x533A;&#x57DF;&#x5185;    <ul>
<li><code>var img = document.createElement( &apos;img&apos; );</code></li>
<li>&#x7ED8;&#x56FE;&#x65F6;&#x9996;&#x5148;&#x9700;&#x8981;&#x51C6;&#x5907;&#x56FE;&#x7247;<ul>
<li>img.src = &#x2018;1.jpg&#x2019;;</li>
</ul>
</li>
<li><code>context.drawImage(img,x&#x8F74;&#x5750;&#x6807;,y&#x8F74;&#x5750;&#x6807;,&#x5BBD;,&#x9AD8;);</code><ul>
<li>&#x7B2C;&#x4E09;&#x79CD;&#x7ED8;&#x5236;&#x56FE;&#x7247;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x7ED8;&#x5236;&#x7CBE;&#x7075;&#x56FE;(&#x7ED3;&#x5408;setInterval();&#x65B9;&#x6CD5;&#x505A;&#x4E00;&#x4E9B;&#x52A8;&#x753B;)</li>
</ul>
</li>
<li><code>context.drawImage(&#x56FE;&#x7247;,&#x622A;&#x53D6;&#x7CBE;&#x7075;&#x56FE;&#x7684;x,&#x622A;&#x53D6;&#x7CBE;&#x7075;&#x56FE;&#x7684;y,&#x622A;&#x53D6;&#x5BBD;&#x5EA6;w,&#x622A;&#x53D6;&#x9AD8;&#x5EA6;&#x5EA6;h,&#x653E;&#x5728;&#x753B;&#x5E03;&#x4E0A;&#x7684;x&#x5750;&#x6807;,&#x653E;&#x5728;&#x753B;&#x5E03;&#x4E0A;&#x7684;y&#x5750;&#x6807;,&#x56FE;&#x7247;&#x6240;&#x5360;&#x753B;&#x5E03;&#x7684;&#x5BBD;,&#x56FE;&#x7247;&#x6240;&#x5360;&#x753B;&#x5E03;&#x7684;&#x9AD8;);</code></li>
<li><code>context.translate(x,y);</code><ul>
<li>&#x5750;&#x6807;&#x5E73;&#x79FB;&#x53D8;&#x6362;</li>
</ul>
</li>
<li><code>context.rotate(&#x5F27;&#x5EA6;);</code><ul>
<li>&#x5750;&#x6807;&#x65CB;&#x8F6C;&#x53D8;&#x6362;&#xFF0C;&#x6700;&#x7B80;&#x5355;&#x5E94;&#x7528;&#xFF1A;&#x65CB;&#x8F6C;&#x7684;&#x6B63;&#x65B9;&#x5F62;</li>
</ul>
</li>
<li><code>context.scale(x,y);</code><ul>
<li>&#x5DE6;&#x8FB9;&#x4F38;&#x7F29;&#x53D8;&#x6362;(x&#x6216;y&#x7F29;&#x653E;&#x7684;&#x500D;&#x6570;,&#x5982;&#x679C;&#x662F;1&#x8868;&#x793A;&#x4E0D;&#x7F29;&#x653E;)&#x6700;&#x7B80;&#x5355;&#x5E94;&#x7528;&#x4E00;&#xFF1A;&#x692D;&#x5706;</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>&#x6CE8;&#xFF1A;&#x53D8;&#x6362;&#x662F;&#x53EF;&#x4EE5;&#x7D2F;&#x52A0;&#x7684;</p>
<h3 id="&#x975E;&#x96F6;&#x73AF;&#x7ED5;&#x539F;&#x5219;"><a href="#&#x975E;&#x96F6;&#x73AF;&#x7ED5;&#x539F;&#x5219;" class="headerlink" title="&#x975E;&#x96F6;&#x73AF;&#x7ED5;&#x539F;&#x5219;"></a>&#x975E;&#x96F6;&#x73AF;&#x7ED5;&#x539F;&#x5219;</h3><p>&#x5728; canvas &#x7ED8;&#x56FE;&#x4E2D;&#x662F;&#x4F7F;&#x7528;&#x8DEF;&#x5F84;&#x63CF;&#x7EBF;&#x7684;&#x65B9;&#x6CD5;&#x7ED8;&#x5236;&#x56FE;&#x5F62;</p>
<p>&#x63CF;&#x70B9;&#x65F6;&#x7684;&#x987A;&#x5E8F;&#x6709;&#x4E00;&#x5B9A;&#x7684;&#x4F5C;&#x7528;, &#x5728;&#x63CF;&#x70B9;&#x65F6;&#x56F4;&#x7ED5;&#x8D77;&#x6765;&#x7684;&#x56FE;&#x5F62;&#x6EE1;&#x8DB3; &#x201C;&#x975E;&#x96F6;&#x73AF;&#x7ED5;&#x539F;&#x5219;&#x201D; &#x7684;&#x533A;&#x57DF;&#x5C31;&#x4F1A;&#x88AB;&#x9542;&#x7A7A;&#x8D77;&#x6765;&#x5982;&#x679C;&#x4E0D;&#x6EE1;&#x8DB3;&#x5C31;&#x4F1A;&#x88AB;&#x586B;&#x5145;.</p>
<ul>
<li>&#x8BA1;&#x7B97;&#x7684;&#x503C;&#x4E3A; 0 &#x5C31; &#x9542;&#x7A7A;, &#x5982;&#x679C;&#x975E;&#x96F6;&#x5C31;&#x662F;&#x586B;&#x5145;</li>
<li>&#x4ECE;&#x56FE;&#x5F62;&#x7684;&#x5185;&#x90E8;&#x62C9;&#x4E00;&#x4E2A;&#x7BAD;&#x5934;, &#x4EE5;&#x7BAD;&#x5934;&#x7684;&#x8D77;&#x70B9;&#x4E3A;&#x5706;&#x5FC3;</li>
<li>&#x68C0;&#x67E5;&#x7A7F;&#x8FC7;&#x7BAD;&#x5934;&#x7684;&#x7EBF;, &#x4EE5;&#x7BAD;&#x5934;&#x8D77;&#x70B9;&#x4E3A;&#x5706;&#x5FC3;&#x5982;&#x679C;&#x987A;&#x65F6;&#x9488;&#x8BB0;&#x4E3A; +1</li>
<li>&#x5982;&#x679C;&#x9006;&#x65F6;&#x9488;&#x8BB0;&#x4E3A; -1, &#x6700;&#x540E;&#x6C42;&#x548C;, &#x5982;&#x679C;&#x4E3A; 0 &#x5219;&#x9542;&#x7A7A;, &#x5982;&#x679C;&#x975E;&#x96F6; &#x5219;&#x586B;&#x5145;</li>
</ul>
<h3 id="&#x5706;&#x4E0A;&#x5750;&#x6807;&#x7684;&#x8BA1;&#x7B97;&#x516C;&#x5F0F;"><a href="#&#x5706;&#x4E0A;&#x5750;&#x6807;&#x7684;&#x8BA1;&#x7B97;&#x516C;&#x5F0F;" class="headerlink" title="&#x5706;&#x4E0A;&#x5750;&#x6807;&#x7684;&#x8BA1;&#x7B97;&#x516C;&#x5F0F;"></a>&#x5706;&#x4E0A;&#x5750;&#x6807;&#x7684;&#x8BA1;&#x7B97;&#x516C;&#x5F0F;</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">x = x0 + r * Math.cos( &#x5F27;&#x5EA6; );</div><div class="line">y = y0 + r * Math.sin( &#x5F27;&#x5EA6; );</div></pre></td></tr></table></figure>
<hr>
<h2 id="&#x8865;&#x5145;"><a href="#&#x8865;&#x5145;" class="headerlink" title="&#x8865;&#x5145;"></a>&#x8865;&#x5145;</h2><ul>
<li>ES5 &#x4E2D;&#x5BF9;&#x6570;&#x7EC4;&#x505A;&#x4E86;&#x6269;&#x5C55;, &#x5F15;&#x5165;&#x4E86; forEach &#x548C; map &#x7B49;&#x65B9;&#x6CD5;</li>
<li>ES6 &#x4E2D;&#x5F15;&#x5165;&#x4E86; &#x7BAD;&#x5934;&#x51FD;&#x6570; arrow function &#x7B80;&#x5316;&#x51FD;&#x6570;&#x7684;&#x4E66;&#x5199;( &#x8FD8;&#x6709;&#x5176;&#x4ED6;&#x7279;&#x5F81; )<ul>
<li>&#x51FD;&#x6570;&#x4E0D;&#x5199; function</li>
<li>&#x53C2;&#x6570;&#x5982;&#x679C;&#x53EA;&#x6709;&#x4E00;&#x4E2A; &#x4E0D;&#x5199;&#x5706;&#x62EC;&#x53F7;</li>
<li>&#x53C2;&#x6570;&#x4E0E;&#x51FD;&#x6570;&#x4F53;&#x7528; =&gt; &#x8FDE;&#x63A5;</li>
<li>&#x51FD;&#x6570;&#x4F53;&#x5982;&#x679C;&#x53EA;&#x6709;&#x4E00;&#x53E5;&#x8BDD;&#x53EF;&#x4EE5;&#x7701;&#x7565;&#x82B1;&#x62EC;&#x53F7;</li>
<li>&#x5982;&#x679C;&#x51FD;&#x6570;&#x4F53;&#x53EA;&#x6709;&#x4E00;&#x53E5;&#x8BDD;, &#x4E14;&#x8FD4;&#x56DE;&#x6570;&#x636E;, &#x53EF;&#x4EE5;&#x7701;&#x7565; return</li>
</ul>
</li>
</ul>
<p>&#x5982;&#xFF1A;<code>var maxX = Math.max.apply( null, points.map(function (v) { return v.x; }));</code></p>
<p>&#x7B80;&#x5199;&#x6210;&#xFF1A;<code>var maxX = Math.max.apply( null, points.map(v=&gt;v.x) );</code></p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>感谢您的支持！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>打 赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="http://ofy7k3v4s.bkt.clouddn.com/wcpayCode.jpg" alt="Hongqin Ma WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="http://ofy7k3v4s.bkt.clouddn.com/apayCode.jpg" alt="Hongqin Ma Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/HTML5/" rel="tag">#HTML5</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2015/01/22/CSS3知识体系/" rel="next" title="CSS3知识体系">
                <i class="fa fa-chevron-left"></i> CSS3知识体系
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2015/03/22/24-PHP-基础/" rel="prev" title="PHP-基础">
                PHP-基础 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <div class="ds-share flat" data-thread-key="2015/02/19/HTML5知识体系/"
     data-title="HTML5知识体系"
     data-content=""
     data-url="https://hongqinma.github.io/2015/02/19/HTML5知识体系/">
  <div class="ds-share-inline">
    <ul  class="ds-share-icons-16">

      <li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
      <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
      <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
      <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
      <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>

    </ul>
    <div class="ds-share-icons-more">
    </div>
  </div>
</div>
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2015/02/19/HTML5知识体系/"
           data-title="HTML5知识体系" data-url="https://hongqinma.github.io/2015/02/19/HTML5知识体系/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            Overview
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="//schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/photo.jpg"
               alt="Hongqin Ma" />
          <p class="site-author-name" itemprop="name">Hongqin Ma</p>
          <p class="site-description motion-element" itemprop="description">Spell at all costs， to rush you in the future. </p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">68</span>
              <span class="site-state-item-name">posts</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">16</span>
                <span class="site-state-item-name">categories</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">57</span>
                <span class="site-state-item-name">tags</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/HongqinMa" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/HongqinMa" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.facebook.com/profile.php?id=100006581058735" target="_blank" title="Facebook">
                  
                    <i class="fa fa-fw fa-facebook"></i>
                  
                  Facebook
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.zhihu.com/people/HirakuMa" target="_blank" title="知乎">
                  
                    <i class="fa fa-fw fa-share-alt"></i>
                  
                  知乎
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              Links
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/rubylouvre/" title="司徒正美" target="_blank">司徒正美</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/sanshi/" title="三生石上" target="_blank">三生石上</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/TomXu/" title="汤姆大叔" target="_blank">汤姆大叔</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://gold.xitu.io/" title="掘金" target="_blank">掘金</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://segmentfault.com/" title="segmentfault" target="_blank">segmentfault</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.jianshu.com/users/1cbb94e5ed4d/latest_articles" title="简书" target="_blank">简书</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://home.cnblogs.com/" title="博客园" target="_blank">博客园</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://www.awesomes.cn/" title="Awesomes" target="_blank">Awesomes</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#简介、h5语义化标签、经典布局"><span class="nav-number">1.</span> <span class="nav-text">简介、h5语义化标签、经典布局</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#表单"><span class="nav-number">2.</span> <span class="nav-text">表单</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#表单元素-注意-datalist-的使用"><span class="nav-number">2.1.</span> <span class="nav-text">表单元素 注意 datalist 的使用</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#表单属性"><span class="nav-number">2.2.</span> <span class="nav-text">表单属性</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#媒体"><span class="nav-number">3.</span> <span class="nav-text">媒体</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#audio标签"><span class="nav-number">3.1.</span> <span class="nav-text">audio标签</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#三种媒体格式"><span class="nav-number">3.1.1.</span> <span class="nav-text">三种媒体格式</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#三种媒体格式-1"><span class="nav-number">3.1.2.</span> <span class="nav-text">三种媒体格式</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#video标签"><span class="nav-number">3.2.</span> <span class="nav-text">video标签</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#三种媒体格式-2"><span class="nav-number">3.2.1.</span> <span class="nav-text">三种媒体格式</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#三种媒体格式-3"><span class="nav-number">3.2.2.</span> <span class="nav-text">三种媒体格式</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#DOM扩展"><span class="nav-number">4.</span> <span class="nav-text">DOM扩展</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#获取元素"><span class="nav-number">4.1.</span> <span class="nav-text">获取元素</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#querySelector-querySelectorAll"><span class="nav-number">4.2.</span> <span class="nav-text">querySelector querySelectorAll</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#类名操作-比较方便"><span class="nav-number">4.3.</span> <span class="nav-text">类名操作(比较方便)</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#自定义属性"><span class="nav-number">4.4.</span> <span class="nav-text">自定义属性</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#jQuery的自定义属性方法data"><span class="nav-number">4.4.1.</span> <span class="nav-text">jQuery的自定义属性方法data();</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#直接操作DOM"><span class="nav-number">4.4.2.</span> <span class="nav-text">直接操作DOM;</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#全屏"><span class="nav-number">5.</span> <span class="nav-text">全屏</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#视频播放器案例"><span class="nav-number">6.</span> <span class="nav-text">视频播放器案例</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#history"><span class="nav-number">7.</span> <span class="nav-text">history</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#本地存储"><span class="nav-number">8.</span> <span class="nav-text">本地存储</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#sessionStorage"><span class="nav-number">8.1.</span> <span class="nav-text">sessionStorage;</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#localStorage"><span class="nav-number">8.2.</span> <span class="nav-text">localStorage</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#geolocation"><span class="nav-number">9.</span> <span class="nav-text">geolocation</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#缓存技术"><span class="nav-number">10.</span> <span class="nav-text">缓存技术</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#拖拽"><span class="nav-number">11.</span> <span class="nav-text">拖拽</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#拖拽元素"><span class="nav-number">11.0.1.</span> <span class="nav-text">拖拽元素</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#目标元素"><span class="nav-number">11.0.2.</span> <span class="nav-text">目标元素</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#文件上传"><span class="nav-number">12.</span> <span class="nav-text">文件上传</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#网络监听的事件"><span class="nav-number">12.1.</span> <span class="nav-text">网络监听的事件</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#canvas"><span class="nav-number">13.</span> <span class="nav-text">canvas</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#简介"><span class="nav-number">13.1.</span> <span class="nav-text">简介</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#canvas-getContext-的-API"><span class="nav-number">13.2.</span> <span class="nav-text">canvas.getContext 的 API</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#非零环绕原则"><span class="nav-number">13.3.</span> <span class="nav-text">非零环绕原则</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#圆上坐标的计算公式"><span class="nav-number">13.4.</span> <span class="nav-text">圆上坐标的计算公式</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#补充"><span class="nav-number">14.</span> <span class="nav-text">补充</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Hongqin Ma</span>
</div>

<div class="powered-by">
  Powered by <a class="theme-link" href="https://hexo.io">Hexo</a>
</div>

<div class="theme-info">
  Theme -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<span id="busuanzi_container_site_pv">
    &nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Page Views: <span id="busuanzi_value_site_pv"></span> 
</span>

        

<div class="busuanzi-count">

  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv"><i class="fa fa-user"></i><span class="busuanzi-value" id="busuanzi_value_site_uv"></span></span>
  

  
    <span class="site-pv"><i class="fa fa-eye"></i><span class="busuanzi-value" id="busuanzi_value_site_pv"></span></span>
  
  
</div>



        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.2"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.2"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"Hiraku"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  






  
  

  

  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("PPmoIQxeu8Sd21h6Tl9TthNx-gzGzoHsz", "rTvbY2H7DvWzRipiBwn72RQ4");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  
  
  <!-- custom analytics part create by xiamo -->
<script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
<script>AV.initialize("PPmoIQxeu8Sd21h6Tl9TthNx-gzGzoHsz", "rTvbY2H7DvWzRipiBwn72RQ4");</script>
<script>
function showTime(Counter) {
  var query = new AV.Query(Counter);
  $(".leancloud_visitors").each(function() {
    var url = $(this).attr("id").trim();
    query.equalTo("url", url);
    query.find({
      success: function(results) {
        if (results.length == 0) {
          var content = '0 ' + $(document.getElementById(url)).text();
          $(document.getElementById(url)).text(content);
          return;
        }
        for (var i = 0; i < results.length; i++) {
          var object = results[i];
          var content = object.get('time') + ' ' + $(document.getElementById(url)).text();
          $(document.getElementById(url)).text(content);
        }
      },
      error: function(object, error) {
        console.log("Error: " + error.code + " " + error.message);
      }
    });

  });
}

function addCount(Counter) {
  var Counter = AV.Object.extend("Counter");
  url = $(".leancloud_visitors").attr('id').trim();
  title = $(".leancloud_visitors").attr('data-flag-title').trim();
  var query = new AV.Query(Counter);
  query.equalTo("url", url);
  query.find({
    success: function(results) {
      if (results.length > 0) {
        var counter = results[0];
        counter.fetchWhenSave(true);
        counter.increment("time");
        counter.save(null, {
          success: function(counter) {
            var content =  counter.get('time') + ' ' + $(document.getElementById(url)).text();
            $(document.getElementById(url)).text(content);
          },
          error: function(counter, error) {
            console.log('Failed to save Visitor num, with error message: ' + error.message);
          }
        });
      } else {
        var newcounter = new Counter();
        newcounter.set("title", title);
        newcounter.set("url", url);
        newcounter.set("time", 1);
        newcounter.save(null, {
          success: function(newcounter) {
              console.log("newcounter.get('time')="+newcounter.get('time'));
            var content = newcounter.get('time') + ' ' + $(document.getElementById(url)).text();
            $(document.getElementById(url)).text(content);
          },
          error: function(newcounter, error) {
            console.log('Failed to create');
          }
        });
      }
    },
    error: function(error) {
      console.log('Error:' + error.code + " " + error.message);
    }
  });
}
$(function() {
  var Counter = AV.Object.extend("Counter");
  if ($('.leancloud_visitors').length == 1) {
    addCount(Counter);
  } else if ($('.post-title-link').length > 1) {
    showTime(Counter);
  }
}); 
</script>

  
</body>
</html>
